package com.aspose.cells;

class zrd {
   public static zrf a(zcgh var0) {
      zrf var1 = null;
      if (var0 == zcgh.a) {
         var1 = a();
      } else {
         com.aspose.cells.a.e.zf.a(false);
      }

      return var1;
   }

   public static zcgi a(zrf var0, byte[] var1, int var2, int var3) {
      int var5 = var2;
      if (var0 != null && var1 != null) {
         if (var0.a.a != zcgh.a) {
            return zcgi.c;
         } else if (var3 == 0) {
            return zcgi.a;
         } else {
            zre var6 = var0.b;
            int var7 = var6.g + (var3 << 3);
            if (var7 < var6.g) {
               ++var6.h;
            }

            var6.h += var3 >> 29;
            var6.g = var7;
            if (var6.a != 0) {
               int var8 = var6.a;
               int var9 = 64 - var6.a;
               if (var3 < var9) {
                  zand.a(var6.b, var8, var1, var2, var3);
                  var6.a += var3;
                  return zcgi.a;
               }

               zand.a(var6.b, var8, var1, var2, var9);
               var5 = var2 + var9;
               var3 -= var9;
               a(var6);
               var6.a = 0;
            }

            while(var3 >= 64) {
               zand.a(var6.b, 0, var1, var5, 64);
               var5 += 64;
               var3 -= 64;
               a(var6);
            }

            zand.a(var6.b, 0, var1, var5, var3);
            var6.a = var3;
            return zcgi.a;
         }
      } else {
         return zcgi.b;
      }
   }

   public static zcgi a(zrf var0, byte[] var1, int var2) {
      byte var4 = 0;
      if (var0 != null && var1 != null) {
         if (var0.a.a != zcgh.a) {
            return zcgi.c;
         } else if (var0.a.b > var2) {
            return zcgi.d;
         } else {
            zre var5 = var0.b;
            int var6 = a(var5.c, var1, var4);
            var6 = a(var5.d, var1, var6);
            var6 = a(var5.e, var1, var6);
            a(var5.f, var1, var6);
            b(var5);
            return zcgi.a;
         }
      } else {
         return zcgi.b;
      }
   }

   private static void a(zre var0) {
      int var1 = var0.c;
      int var2 = var0.d;
      int var3 = var0.e;
      int var4 = var0.f;
      int[] var5 = var0.b;
      var1 += (int)((long)var5[0] + 3614090360L + (long)a(var2, var3, var4));
      var1 = a(var1, 7);
      var1 += var2;
      var4 += (int)((long)var5[1] + 3905402710L + (long)a(var1, var2, var3));
      var4 = a(var4, 12);
      var4 += var1;
      var3 += (int)((long)var5[2] + 606105819L + (long)a(var4, var1, var2));
      var3 = a(var3, 17);
      var3 += var4;
      var2 += (int)((long)var5[3] + 3250441966L + (long)a(var3, var4, var1));
      var2 = a(var2, 22);
      var2 += var3;
      var1 += (int)((long)var5[4] + 4118548399L + (long)a(var2, var3, var4));
      var1 = a(var1, 7);
      var1 += var2;
      var4 += (int)((long)var5[5] + 1200080426L + (long)a(var1, var2, var3));
      var4 = a(var4, 12);
      var4 += var1;
      var3 += (int)((long)var5[6] + 2821735955L + (long)a(var4, var1, var2));
      var3 = a(var3, 17);
      var3 += var4;
      var2 += (int)((long)var5[7] + 4249261313L + (long)a(var3, var4, var1));
      var2 = a(var2, 22);
      var2 += var3;
      var1 += (int)((long)var5[8] + 1770035416L + (long)a(var2, var3, var4));
      var1 = a(var1, 7);
      var1 += var2;
      var4 += (int)((long)var5[9] + 2336552879L + (long)a(var1, var2, var3));
      var4 = a(var4, 12);
      var4 += var1;
      var3 += (int)((long)var5[10] + 4294925233L + (long)a(var4, var1, var2));
      var3 = a(var3, 17);
      var3 += var4;
      var2 += (int)((long)var5[11] + 2304563134L + (long)a(var3, var4, var1));
      var2 = a(var2, 22);
      var2 += var3;
      var1 += (int)((long)var5[12] + 1804603682L + (long)a(var2, var3, var4));
      var1 = a(var1, 7);
      var1 += var2;
      var4 += (int)((long)var5[13] + 4254626195L + (long)a(var1, var2, var3));
      var4 = a(var4, 12);
      var4 += var1;
      var3 += (int)((long)var5[14] + 2792965006L + (long)a(var4, var1, var2));
      var3 = a(var3, 17);
      var3 += var4;
      var2 += (int)((long)var5[15] + 1236535329L + (long)a(var3, var4, var1));
      var2 = a(var2, 22);
      var2 += var3;
      var1 += (int)((long)var5[1] + 4129170786L + (long)b(var2, var3, var4));
      var1 = a(var1, 5);
      var1 += var2;
      var4 += (int)((long)var5[6] + 3225465664L + (long)b(var1, var2, var3));
      var4 = a(var4, 9);
      var4 += var1;
      var3 += (int)((long)var5[11] + 643717713L + (long)b(var4, var1, var2));
      var3 = a(var3, 14);
      var3 += var4;
      var2 += (int)((long)var5[0] + 3921069994L + (long)b(var3, var4, var1));
      var2 = a(var2, 20);
      var2 += var3;
      var1 += (int)((long)var5[5] + 3593408605L + (long)b(var2, var3, var4));
      var1 = a(var1, 5);
      var1 += var2;
      var4 += (int)((long)var5[10] + 38016083L + (long)b(var1, var2, var3));
      var4 = a(var4, 9);
      var4 += var1;
      var3 += (int)((long)var5[15] + 3634488961L + (long)b(var4, var1, var2));
      var3 = a(var3, 14);
      var3 += var4;
      var2 += (int)((long)var5[4] + 3889429448L + (long)b(var3, var4, var1));
      var2 = a(var2, 20);
      var2 += var3;
      var1 += (int)((long)var5[9] + 568446438L + (long)b(var2, var3, var4));
      var1 = a(var1, 5);
      var1 += var2;
      var4 += (int)((long)var5[14] + 3275163606L + (long)b(var1, var2, var3));
      var4 = a(var4, 9);
      var4 += var1;
      var3 += (int)((long)var5[3] + 4107603335L + (long)b(var4, var1, var2));
      var3 = a(var3, 14);
      var3 += var4;
      var2 += (int)((long)var5[8] + 1163531501L + (long)b(var3, var4, var1));
      var2 = a(var2, 20);
      var2 += var3;
      var1 += (int)((long)var5[13] + 2850285829L + (long)b(var2, var3, var4));
      var1 = a(var1, 5);
      var1 += var2;
      var4 += (int)((long)var5[2] + 4243563512L + (long)b(var1, var2, var3));
      var4 = a(var4, 9);
      var4 += var1;
      var3 += (int)((long)var5[7] + 1735328473L + (long)b(var4, var1, var2));
      var3 = a(var3, 14);
      var3 += var4;
      var2 += (int)((long)var5[12] + 2368359562L + (long)b(var3, var4, var1));
      var2 = a(var2, 20);
      var2 += var3;
      var1 += (int)((long)var5[5] + 4294588738L + (long)c(var2, var3, var4));
      var1 = a(var1, 4);
      var1 += var2;
      var4 += (int)((long)var5[8] + 2272392833L + (long)c(var1, var2, var3));
      var4 = a(var4, 11);
      var4 += var1;
      var3 += (int)((long)var5[11] + 1839030562L + (long)c(var4, var1, var2));
      var3 = a(var3, 16);
      var3 += var4;
      var2 += (int)((long)var5[14] + 4259657740L + (long)c(var3, var4, var1));
      var2 = a(var2, 23);
      var2 += var3;
      var1 += (int)((long)var5[1] + 2763975236L + (long)c(var2, var3, var4));
      var1 = a(var1, 4);
      var1 += var2;
      var4 += (int)((long)var5[4] + 1272893353L + (long)c(var1, var2, var3));
      var4 = a(var4, 11);
      var4 += var1;
      var3 += (int)((long)var5[7] + 4139469664L + (long)c(var4, var1, var2));
      var3 = a(var3, 16);
      var3 += var4;
      var2 += (int)((long)var5[10] + 3200236656L + (long)c(var3, var4, var1));
      var2 = a(var2, 23);
      var2 += var3;
      var1 += (int)((long)var5[13] + 681279174L + (long)c(var2, var3, var4));
      var1 = a(var1, 4);
      var1 += var2;
      var4 += (int)((long)var5[0] + 3936430074L + (long)c(var1, var2, var3));
      var4 = a(var4, 11);
      var4 += var1;
      var3 += (int)((long)var5[3] + 3572445317L + (long)c(var4, var1, var2));
      var3 = a(var3, 16);
      var3 += var4;
      var2 += (int)((long)var5[6] + 76029189L + (long)c(var3, var4, var1));
      var2 = a(var2, 23);
      var2 += var3;
      var1 += (int)((long)var5[9] + 3654602809L + (long)c(var2, var3, var4));
      var1 = a(var1, 4);
      var1 += var2;
      var4 += (int)((long)var5[12] + 3873151461L + (long)c(var1, var2, var3));
      var4 = a(var4, 11);
      var4 += var1;
      var3 += (int)((long)var5[15] + 530742520L + (long)c(var4, var1, var2));
      var3 = a(var3, 16);
      var3 += var4;
      var2 += (int)((long)var5[2] + 3299628645L + (long)c(var3, var4, var1));
      var2 = a(var2, 23);
      var2 += var3;
      var1 += (int)((long)var5[0] + 4096336452L + (long)d(var2, var3, var4));
      var1 = a(var1, 6);
      var1 += var2;
      var4 += (int)((long)var5[7] + 1126891415L + (long)d(var1, var2, var3));
      var4 = a(var4, 10);
      var4 += var1;
      var3 += (int)((long)var5[14] + 2878612391L + (long)d(var4, var1, var2));
      var3 = a(var3, 15);
      var3 += var4;
      var2 += (int)((long)var5[5] + 4237533241L + (long)d(var3, var4, var1));
      var2 = a(var2, 21);
      var2 += var3;
      var1 += (int)((long)var5[12] + 1700485571L + (long)d(var2, var3, var4));
      var1 = a(var1, 6);
      var1 += var2;
      var4 += (int)((long)var5[3] + 2399980690L + (long)d(var1, var2, var3));
      var4 = a(var4, 10);
      var4 += var1;
      var3 += (int)((long)var5[10] + 4293915773L + (long)d(var4, var1, var2));
      var3 = a(var3, 15);
      var3 += var4;
      var2 += (int)((long)var5[1] + 2240044497L + (long)d(var3, var4, var1));
      var2 = a(var2, 21);
      var2 += var3;
      var1 += (int)((long)var5[8] + 1873313359L + (long)d(var2, var3, var4));
      var1 = a(var1, 6);
      var1 += var2;
      var4 += (int)((long)var5[15] + 4264355552L + (long)d(var1, var2, var3));
      var4 = a(var4, 10);
      var4 += var1;
      var3 += (int)((long)var5[6] + 2734768916L + (long)d(var4, var1, var2));
      var3 = a(var3, 15);
      var3 += var4;
      var2 += (int)((long)var5[13] + 1309151649L + (long)d(var3, var4, var1));
      var2 = a(var2, 21);
      var2 += var3;
      var1 += (int)((long)var5[4] + 4149444226L + (long)d(var2, var3, var4));
      var1 = a(var1, 6);
      var1 += var2;
      var4 += (int)((long)var5[11] + 3174756917L + (long)d(var1, var2, var3));
      var4 = a(var4, 10);
      var4 += var1;
      var3 += (int)((long)var5[2] + 718787259L + (long)d(var4, var1, var2));
      var3 = a(var3, 15);
      var3 += var4;
      var2 += (int)((long)var5[9] + 3951481745L + (long)d(var3, var4, var1));
      var2 = a(var2, 21);
      var2 += var3;
      var0.c += var1;
      var0.d += var2;
      var0.e += var3;
      var0.f += var4;
   }

   private static zrf a() {
      zrf var0 = new zrf();
      var0.a.a = zcgh.a;
      var0.a.b = 16;
      b(var0.b);
      return var0;
   }

   private static void b(zre var0) {
      var0.c = 1732584193;
      var0.d = -271733879;
      var0.e = -1732584194;
      var0.f = 271733878;
   }

   private static int a(int var0, int var1, int var2) {
      return (var1 ^ var2) & var0 ^ var2;
   }

   private static int b(int var0, int var1, int var2) {
      return (var0 ^ var1) & var2 ^ var1;
   }

   private static int c(int var0, int var1, int var2) {
      return var0 ^ var1 ^ var2;
   }

   private static int d(int var0, int var1, int var2) {
      return (var0 | ~var2) ^ var1;
   }

   private static int a(int var0, int var1) {
      return var0 << var1 | var0 >>> 32 - var1;
   }

   private static int a(int var0, byte[] var1, int var2) {
      var1[var2++] = (byte)(var0 & 255);
      var1[var2++] = (byte)(var0 >>> 8 & 255);
      var1[var2++] = (byte)(var0 >>> 16 & 255);
      var1[var2++] = (byte)(var0 >>> 24 & 255);
      return var2;
   }
}
